// 数据库中的数据
let persons = [{ "username": "xm1", "password": "1234" }, { "username": "xm2", "password": "222" }, { "username": "xm3", "password": "333" }]

// 用户提交过来的数据
let user = { username: "admin1", password: "12345" }


// 判断数据库中是否有此用户
// some   find   findIndex

let index=persons.findIndex(value=>user.username==value.username )

if(index==-1){
    // console.log("请注册吧");
    // 执行注册

    persons.push(user)

    console.log("注册成功");
}else{

    console.log("用户名已被占用");
}

